﻿using System.Collections.Generic;
using System.Text.RegularExpressions;

public class TripleRegex
{
    public List<Triple> ExtractTriplesFromText(string text)
    {
        Regex regex = new Regex(@"\((?<A>\d+)\,\s(?<B>\d+)\,\s(?<C>\d+)\)");
        var matches = regex.Matches(text);
        List<Triple> triples = new List<Triple>();
        foreach (Match item in matches)
        {
            Group a = item.Groups["A"];
            int aAsInteger = int.Parse(a.Value);
            Group b = item.Groups["B"];
            int bAsInteger = int.Parse(b.Value);
            Group c = item.Groups["C"];
            int cAsInteger = int.Parse(c.Value);
            Triple triple = new Triple(aAsInteger, bAsInteger, cAsInteger);
            triples.Add(triple);
        }
        return triples;
    }
}